﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;

    public class SysModule
    {
        private readonly Chain.IDAL.SysModule dal = new Chain.IDAL.SysModule();

        public int Add(Chain.Model.SysModule model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.SysModule> DataTableToList(DataTable dt)
        {
            List<Chain.Model.SysModule> list = new List<Chain.Model.SysModule>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.SysModule item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return list;
        }

        public bool Delete(int ModuleID)
        {
            return this.dal.Delete(ModuleID);
        }

        public bool DeleteList(string ModuleIDlist)
        {
            return this.dal.DeleteList(ModuleIDlist);
        }

        public bool Exists(int ModuleID)
        {
            return this.dal.Exists(ModuleID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetAllList(string strSql)
        {
            return this.GetList(strSql);
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public int GetMaxId()
        {
            return this.dal.GetMaxId();
        }

        public Chain.Model.SysModule GetModel(int ModuleID)
        {
            return this.dal.GetModel(ModuleID);
        }

        public List<Chain.Model.SysModule> GetModelList(int moduleParentID)
        {
            return this.DataTableToList(this.dal.GetList(moduleParentID));
        }

        public List<Chain.Model.SysModule> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public void SetEnableGoods(bool enableGoods)
        {
            string item = "66,67,69,76,87,91,113,114,118";
            string str2 = "60";
            List<bool> list3 = new List<bool>();
            list3.Add(enableGoods);
            list3.Add(enableGoods);
            List<bool> status = list3;
            List<string> list4 = new List<string>();
            list4.Add(str2);
            list4.Add(item);
            List<string> moduleIDs = list4;
            new Chain.BLL.SysParameter().SwitchingMode(status, moduleIDs);
        }

        public bool Update(Chain.Model.SysModule model)
        {
            return this.dal.Update(model);
        }

        public int UpdateIsDataInit(int intType)
        {
            return this.dal.UpdateIsDataInit(intType);
        }
    }
}

